<template>
	<view class="container">
		<uni-section title="评论列表展示" type="line">
			<uni-list>
				<uni-list-item v-for="(item,index) in comments" :title="item.comment" clickable @click="commentOne(item.id)"></uni-list-item>
				
			</uni-list>
			
		</uni-section>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				comments:[
					
				]
			}
		},
		methods: {
			commentOne(id){
				uni.navigateTo({
					url:"../commentdetail/commentdetail?id="+id
				})
			}
		},
		// onLoad: () => {
		// 	uni.onTabBarMidButtonTap(function(e){
		// 		console.log(e)
				
		// 	})
		// }
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/foodapp/comment/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.comments = res.data.list
						uni.showToast({
							title: '成功',
							icon: 'none'
						});
					} else {
						uni.showToast({
							title: '失败',
							icon: 'none'
						});
					}
				},
				fail: () => {
					uni.showToast({
						title: '失败',
						icon: 'none'
					});
				},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
